package com.zeltov.eo;

import org.hibernate.*;

import com.zeltov.domain.Car;

import util.HibernateUtil;

@SuppressWarnings(value={"unchecked"}) 
public class Driver {
    
        

    /**
     * @param args
     */

    public static void main(String[] args) {
        
    	SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    	Session session = sessionFactory.openSession();

        Transaction transaction = session.beginTransaction();
        
        Car car = new CarEO();
        car.setName("mycar1");
        
        session.save(car);
        
        transaction.commit();

        session.close();
        
        System.out.println(car);
        
        car = null;
        
        
        System.out.println("\nNow about to read from database and show results\n");
        
        session = sessionFactory.openSession();
        
        HibernateUtil.getSessionFactory().close();
    }
}